package com.fa.service.impl;

import com.fa.common.core.domain.AjaxResult;
import com.fa.common.utils.DateUtils;
import com.fa.common.utils.SecurityUtils;
import com.fa.domain.MdUnitDTO;
import com.fa.domain.MdUnitMeasure;
import com.fa.domain.MdVendor;
import com.fa.mapper.MdUnitMapper;
import com.fa.service.IMdUnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.security.Security;
import java.util.Date;
import java.util.List;
@Service
public class MdUnitServiceImpl implements IMdUnitService {
    @Autowired
    private MdUnitMapper mdUnitMapper;

    @Override
    public List<MdUnitMeasure> selectMdUnitList(MdUnitDTO mdUnitDTO) {
        List<MdUnitMeasure> mdUnitMeasures = mdUnitMapper.selectMdUnitList(mdUnitDTO);
        return mdUnitMeasures;
    }

    @Override
   public List<MdUnitMeasure> selectMdUnitListPrimary(){
        List<MdUnitMeasure> mdUnitMeasures = mdUnitMapper.selectMdUnitListPrimary();
        return mdUnitMeasures;
    }
    @Override
    public Integer add(MdUnitMeasure mdUnitMeasure) {

        mdUnitMeasure.setCreateTime(new Date());
        mdUnitMeasure.setUpdateTime(new Date());
        String username = SecurityUtils.getUsername();
        mdUnitMeasure.setCreateBy(username);
        mdUnitMeasure.setUpdateBy(username);
        return mdUnitMapper.add(mdUnitMeasure);
    }

    @Override
    public int updateMdUnit( MdUnitMeasure mdUnitMeasure)
    {
        mdUnitMeasure.setUpdateTime(DateUtils.getNowDate());
        return mdUnitMapper.updateMdUnit(mdUnitMeasure);
    }

    @Override
    public int delete(Long unitId)
    {
        return mdUnitMapper.deleteMdUnit(unitId);
    }

    /**
     * 批量删除
     *
     * @param
     * @return 结果
     */
    @Override
    public int deleteMdUnitByUnitIds(Long[] unitIds)
    {
        return mdUnitMapper.deleteMdUnitByUnitIds(unitIds);
    }

}
